package com.example.smarthome.ui.gallery;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.smarthome.databinding.FragmentGalleryBinding;

public class GalleryFragment extends Fragment {

    private FragmentGalleryBinding binding;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        GalleryViewModel galleryViewModel =
                new ViewModelProvider(this).get(GalleryViewModel.class);

        binding = FragmentGalleryBinding.inflate(inflater, container, false);
        View root = binding.getRoot();

        final TextView textView = binding.out;
        galleryViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);

           binding.kong1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent =new Intent("com.example.activitytest.ACTION_START");
//                intent.addCategory("com.example.activitytest.GalleryActivity");
//                startActivity(intent);
//                Log.i("SecondActivity","22");
            }
        });

//        binding.kong2.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent =new Intent("com.example.activitytest.LAMP_START");
//                intent.addCategory("com.example.activitytest.GalleryLampActivity");
//                startActivity(intent);
//                Log.i("SecondActivity","22");
//            }
//        });

        binding.galleryLamp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("玄关灯开关", "onClick: ");
            }
        });
        binding.galleryDoorLock.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("玄关门锁开关", "onClick: ");
            }
        });
        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}